<?php

namespace App\Http\Requests\Collection;

use Illuminate\Foundation\Http\FormRequest;

class BaseRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch($this->method()) {
            case 'POST': {
                return [
                    'sign' => 'required',
                    'content' => 'required|json'
                ];
            }
        }
        return [];
    }

    /**
     * 验证信息返回
     *
     * @return array
     */
    public function messages()
    {
        return [
            'sign.required' => '缺少sign',
            'content.required' => '缺少内容',
            'content.json' => '内容格式错误',
        ];
    }
}
